package com.meng.jingtao.product.service.impl;

import com.meng.common.utils.Msg;
import com.meng.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meng.common.utils.PageUtils;
import com.meng.common.utils.Query;

import com.meng.jingtao.product.dao.AttrAttrgroupRelationDao;
import com.meng.jingtao.product.entity.AttrAttrgroupRelationEntity;
import com.meng.jingtao.product.service.AttrAttrgroupRelationService;


@Service("attrAttrgroupRelationService")
public class AttrAttrgroupRelationServiceImpl extends ServiceImpl<AttrAttrgroupRelationDao, AttrAttrgroupRelationEntity> implements AttrAttrgroupRelationService {

    @Autowired
    AttrAttrgroupRelationDao attrAttrgroupRelationDao;


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AttrAttrgroupRelationEntity> page = this.page(
                new Query<AttrAttrgroupRelationEntity>().getPage(params),
                new QueryWrapper<AttrAttrgroupRelationEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public Msg<AttrAttrgroupRelationEntity> getAttrById(Long id) {
        try{
           AttrAttrgroupRelationEntity attrAttrgroupRelationEntity =  attrAttrgroupRelationDao.selectAttrById(id);
           if (attrAttrgroupRelationEntity == null) {
               return Msg.fail("根据id查询详情不存在");
           }
           Msg.sucess(attrAttrgroupRelationEntity);

        }catch (Exception e) {
            log.error("根据属性id查询属性详情失败,失败原因:",e);
            return Msg.fail("根据属性id查询属性详情失败");
        }
        return null;
    }

}